package cn.edu.scau.daoImpl;

import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import cn.edu.scau.dao.SingleDao;
import cn.edu.scau.entity.Single;

@Repository("singleDaoImpl")
public class SingleDaoImpl extends BaseDaoImpl<Single> implements SingleDao {

	@Override
	public Single getSingleEntityByColumnID(Integer columnID) {

		// 获得session
		Session session = getSessionFactory().openSession();
		// hql语句
		String hql = "from Single s where ColumnID = ?0";
		Object[] objs = new Object[1];
		objs[0] = columnID;
		// 执行操作
		List<Single> singles = this.findByHql(hql, objs);
		// flush到数据库
		session.flush();
		// 关闭session
		session.close();
		if (singles != null && singles.size() > 0) {
			return singles.get(0);
		}

		return null;
	}

}
